package com.itheima.consumer.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author dataexa
 */
@Configuration
public class DirectConfiguration {
    private final DirectExchange directExchange = new DirectExchange("hmall.direct");
    private final Queue directQueue1 = new Queue("direct.queue1");
    private final Queue directQueue2 = new Queue("direct.queue2");

    @Bean
    public DirectExchange directExchange() {
        return directExchange;
    }

    @Bean
    public Queue directQueue1() {
        return directQueue1;
    }

    @Bean
    public Binding directQueue1BindingRed() {
        return BindingBuilder.bind(directQueue1).to(directExchange).with("red");
    }

    @Bean
    public Binding directQueue1BindingBlue() {
        return BindingBuilder.bind(directQueue1).to(directExchange).with("blue");
    }

    @Bean
    public Queue directQueue2() {
        return directQueue2;
    }

    @Bean
    public Binding directQueue2BindingRed() {
        return BindingBuilder.bind(directQueue2).to(directExchange).with("red");
    }

    @Bean
    public Binding directQueue2BindingBlue() {
        return BindingBuilder.bind(directQueue2).to(directExchange).with("yellow");
    }

}
